using Fiddler;
using System.Collections.Generic;

namespace TangCaptureTraffic.Services
{
    /// <summary>
    /// 会话服务接口，定义会话管理的核心功能
    /// </summary>
    public interface ISessionService
    {
        /// <summary>
        /// 会话添加事件
        /// </summary>
        event Action<Session> SessionAdded;
        
        /// <summary>
        /// 会话完成事件
        /// </summary>
        event Action<Session> SessionCompleted;
        
        /// <summary>
        /// 获取所有会话
        /// </summary>
        /// <returns>会话集合</returns>
        IEnumerable<Session> GetAllSessions();
        
        /// <summary>
        /// 根据ID获取会话
        /// </summary>
        /// <param name="sessionId">会话ID</param>
        /// <returns>会话对象，如果不存在则返回null</returns>
        Session GetSessionById(int sessionId);
        
        /// <summary>
        /// 清理旧会话
        /// </summary>
        /// <param name="count">要清理的会话数量</param>
        void CleanupOldSessions(int count);
        
        /// <summary>
        /// 获取会话总数
        /// </summary>
        /// <returns>会话总数</returns>
        int GetSessionCount();
        
        /// <summary>
        /// 清空所有会话
        /// </summary>
        void ClearAllSessions();
        
        /// <summary>
        /// 重发会话请求
        /// </summary>
        /// <param name="session">要重发的会话</param>
        /// <returns>新的会话对象，失败时返回null</returns>
        Session ResendSession(Session session);

        /// <summary>
        /// 导出会话到文件
        /// </summary>
        /// <param name="sessions">要导出的会话集合</param>
        /// <param name="filePath">导出文件路径</param>
        /// <returns>导出是否成功</returns>
        bool ExportSessions(IEnumerable<Session> sessions, string filePath);

        /// <summary>
        /// 从文件导入会话
        /// </summary>
        /// <param name="filePath">导入文件路径</param>
        /// <returns>导入的会话集合</returns>
        IEnumerable<Session> ImportSessions(string filePath);

        /// <summary>
        /// 添加新会话
        /// </summary>
        /// <param name="session">要添加的会话</param>
        void AddSession(Session session);

        /// <summary>
        /// 标记会话完成
        /// </summary>
        /// <param name="session">完成的会话</param>
        void CompleteSession(Session session);

        /// <summary>
        /// 删除指定的会话
        /// </summary>
        /// <param name="sessions">要删除的会话集合</param>
        /// <returns>成功删除的会话数量</returns>
        int RemoveSessions(IEnumerable<Session> sessions);
    }
}